<?php  

$url = 'http://www.weather.com.cn/weather/101090209.shtml';

$page_content = file_get_contents($url);
$day = date('Y-m-d');

$pattern = '/（今天）.*?<\/li>/s';  
preg_match_all($pattern, $page_content, $res);

$str = $res[0][0];
$patternTianqi = '/class="wea">(.*?)<\/p>/s';
preg_match_all($patternTianqi, $str, $resTianqi);
$patternWendu = '/<i>(.*?℃)<\/i>/s';
preg_match_all($patternWendu, $str, $resWendu);

$todayTianqi = $resTianqi[1][0];
$todayWendu = $resWendu[1][0];

if (!$todayTianqi) {
    return ['code' => 1, 'msg' => '获取失败'];
}
return ['code' => 0, 'msg' => '获取成功', 'data' => ['day' => $day, 'tianqi' => $todayTianqi, 'wendu' => $todayWendu]];